#ifndef MISSIONWIDGET_H
#define MISSIONWIDGET_H

#include"ui_mission.h"
#include<QValidator>
#include<QMap>

#include"serialize/mission.h"
#include"serialize/equipment.h"
#include"serialize/general.h"
#include"serialize/fragment.h"
#include"serialize/utils.h"

namespace Ui{
class MissionWidget;
}

class MissionWidget : public QWidget
{
    Q_OBJECT

public:
    explicit MissionWidget(QWidget* p=0);
    ~MissionWidget();

    void setFilePath(QString s);
    inline void setWorkPath(QString s){workPath=s;}
    void initialMap();
    void addTreeItems(QList<QTreeWidgetItem*> items);

    Mission getMissionFromUI();
    void displayMissionToUI(Mission& m);
    Mission readMissionFromFile();
    bool saveMissionToFile();

    static void exportToBinary(QString workspacepath);
    static void exportToXML(QString workspacepath);
    static bool importFromXML(QString workspacepath,QString xmlFile);

    void clearUI();

    Ui::MissionWidget* ui;

public slots:
    void s_rewardItemDoubleClicked(QTreeWidgetItem* item,int col);
    void s_cellDoubleClicked(int row, int column);

private:
//    bool isSaved;
    QString filePath;
    QString workPath;
    QMap<int,QString> equipMap;
    QMap<int,QString> generalMap;
    QMap<int,QString> fragmentMap;
    void setInputMask();
};

#endif // MISSIONWIDGET_H
